//
//  Point_and_reference.hpp
//  learnC++
//
//  Created by liuzhibing on 2018/6/14.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef Point_and_reference_hpp
#define Point_and_reference_hpp

#include <stdio.h>
#include <iostream>

class Base7
{
protected:
    int m_value;
    
public:
    Base7(int value)
    : m_value(value)
    {
    }
    
    const char* getName() { return "Base"; }
    int getValue() { return m_value; }
};

class Derived7: public Base7
{
public:
    Derived7(int value)
    : Base7(value)
    {
    }
    
    const char* getName() { return "Derived"; }
    int getValueDoubled() { return m_value * 2; }
};

/*
 应该还是命名空间的问题，虽然继承，但是创建的对象依然可以使用命名空间来管理的，编译器根据指针类型来调用方法，和OC不同
 Derived7 *d = new Derived7(7);
 Base7 *pb = d;
 std::cout << "derived is a " << d->getName() << " and has value " << d->getValue() << '\n';
 std::cout << "pBase is a " << pb->getName() << " and has value " << pb->getValue() << '\n';
 */

#endif /* Point_and_reference_hpp */
